#include<regx52.h>
#define b1 P3_7
#define b2 P3_3
#define b3 P3_4
#define b4 P3_2
#define mode P3_0
int dem;			 
unsigned char font1[10]={0x14,0xd7,0x4c,0x45,0x87,0x25,0x24,0x57,0x04,0x05};
void delayQuet()
{
	int i;
	for(i =0;i<1000;i++){};		
}	

void quet()
{
	/////////////////////
	if(mode)
	{
		b1 = 0;
		P1=font1[dem/1000];
		delayQuet();
		b1=1;
	}
	else b1=1;
	///////////////////
	b2=0;
	P1=font1[(dem/100)%10]&0xfb;
	
	delayQuet();
	b2=1;
	//////////////////
	b3=0;
	P1=font1[(dem/10)%10];
	delayQuet();
	b3=1;
	/////////////////
	b4=0;
	P1=font1[dem%10];
	delayQuet();
	b4=1;
	////////////////
}	
void main()
{
	P3_5=1;
	EA =1;
	ET1=1;
	TMOD = 0x60;
	TH1=0xff;
	TL1=0xff;
	TR1=1;
	dem=0;
	while(1)
	{	
		quet();		 		
	}
}
void ngatT1(void) interrupt 3
{
	if((mode==1&&dem<9999)||(mode == 0 &&dem<999))
		dem++;
}